package com.ipan.builder.ognl;

import java.util.Map;

import ognl.OgnlRuntime;

import com.ipan.builder.util.CompoundRoot;

/**
 * OGNL值栈创建工厂
 * 
 * @author iPan
 * @version 2013-12-1
 */
public class OgnlValueStackManager {

	// 注册CompoundRoot访问器
	static {
		OgnlRuntime.setPropertyAccessor(CompoundRoot.class, OgnlValueStack.COMPOUNDROOT_ACCESSOR);
		OgnlRuntime.setMethodAccessor(CompoundRoot.class, OgnlValueStack.COMPOUNDROOT_ACCESSOR);
	}
	
	/**
	 * 创建OgnlValueStack，默认不能访问静态成员；
	 */
	public static OgnlValueStack createOgnlValueStack() {
		return new OgnlValueStack();
	}
	
	public static OgnlValueStack createOgnlValueStack(CompoundRoot root, boolean allowStaticMethodAccess) {
		return new OgnlValueStack(root, null, allowStaticMethodAccess);
	}
	
	public static OgnlValueStack createOgnlValueStack(CompoundRoot root, Map<String, Object> vsContext, boolean allowStaticMethodAccess) {
		return new OgnlValueStack(root, vsContext, allowStaticMethodAccess);
	}
	
	public static OgnlValueStack createOgnlValueStack(ValueStack vs, boolean allowStaticMethodAccess) {
		return new OgnlValueStack(vs, null, allowStaticMethodAccess);
	}
	
	public static OgnlValueStack createOgnlValueStack(ValueStack vs, Map<String, Object> context, boolean allowStaticMethodAccess) {
		return new OgnlValueStack(vs, context, allowStaticMethodAccess);
	}
	
}
